<template>
  <van-goods-action>
    <van-goods-action-icon
      :icon="isColoect ? 'star' : 'star-o'"
      :text="isColoect ? '已收藏' : '未收藏'"
      :color="isColoect ? 'darkred' : '#666'"
      @click="isColoect = !isColoect"
    />
    <van-goods-action-icon
      icon="cart-o"
      @click="toCart"
      text="购物车"
      :badge="badge"
    />
    <van-goods-action-button
      color="#7232dd"
      type="danger"
      @click="buyNow"
      text="立即购买"
    />
    <van-goods-action-button
      color="#be99ff"
      type="warning"
      @click="addToCart"
      text="加入购物车"
    />
  </van-goods-action>
</template>

<script>
export default {
  props: ['badge'],
  data () {
    return {
      isColoect: false
    }
  },
  methods: {
    buyNow () {
      this.$toast('该功能暂未开放')
    },
    addToCart () {
      this.$emit('addToCart')
    },
    toCart () {
      this.$router.push('/cart')
    }
  }
}
</script>

<style lang="less" scoped></style>
